//
//  MyPmCell.m
//  diaoyuren
//
//  Created by 钓鱼人 on 16/4/20.
//  Copyright © 2016年 game. All rights reserved.
//

#import "MyPmCell.h"
#import "NSString+HtmlCharact.h"
#import "UILabel+BoundRect.h"

@interface MyPmCell ()
@property (weak, nonatomic) IBOutlet UIButton *headImage;
@property (weak, nonatomic) IBOutlet MBButtonWithFontAdapter *name;
@property (weak, nonatomic) IBOutlet MBLabelWithFontAdapter *time;
@property (weak, nonatomic) IBOutlet MBLabelWithFontAdapter *content;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *headWidth;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *headHeight;
@property (weak, nonatomic) IBOutlet UILabel *footView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *footHight;

@end

@implementation MyPmCell

- (void)awakeFromNib {
    
    self.selectionStyle = 0;
    self.footView.backgroundColor = tabPlainBackColor;
    self.footHight.constant = SCREEN_HEIGHT*0.03;
    
    self.headHeight.constant = SCREEN_WIDTH*0.07;
    self.headWidth.constant = self.headHeight.constant;
    radius(self.headImage, self.headHeight.constant/2);
    
}

-(void)setModel:(MyPmListModel *)model{
    _model = model;

    [self.headImage sd_setImageWithURL:[NSURL URLWithString:_model.avatar] forState:UIControlStateNormal];
    
    [self.name setTitle:_model.msgfrom forState:UIControlStateNormal];
    self.time.text = [_model.vdateline filterresult];
    self.content.text = _model.message;
    
    CGRect sizerect = [_content boundingRectWithInitSize:CGSizeMake(SCREEN_WIDTH-24, 0)];
    
    self.cellHight = sizerect.size.height+SCREEN_HEIGHT*0.12;

}

//用户头像与用户名字点击事件
- (IBAction)spaceClick:(UIButton *)sender {
    
    if ([self.deleget respondsToSelector:@selector(ToSpaceWhithUid:)]) {
        
        [self.deleget ToSpaceWhithUid:_model.msgfromid];
    }
}
@end
